public class test3 {
    //力扣  152.乘积最大子数组
    public int maxProduct(int[] nums) {
        //创建dp数组
        //初始化
        //填表
        //返回值
        int n = nums.length;
        int[] dpmax = new int[n+1];
        int[] dpmin = new int[n+1];
        dpmax[0] = 1;
        dpmin[0] = 1;
        int max = Integer.MIN_VALUE;
        for(int i = 1;i<n+1;i++){
            int tmp = nums[i-1];
            dpmax[i] = Math.max(tmp,Math.max(dpmax[i-1]*tmp , dpmin[i-1]*tmp));
            dpmin[i] = Math.min(tmp,Math.min(dpmax[i-1]*tmp , dpmin[i-1]*tmp));
            //从dpmax表找即可，因为dpmin表是最小乘积
            max = Math.max(max,dpmax[i]);
        }
        return max;
    }
}
